/**
 * HQLDeleteCreator.java
 * 卢晓峰
 * Email：lxf9601@gmail.com
 * QQ：297051898
 * Created by 2010-7-18
 */
package com.autoabacus.core.config.provider.creator;

import com.autoabacus.core.config.component.Table;
import com.autoabacus.core.config.provider.HQLCreator;
import com.autoabacus.core.config.provider.QuerySource;

/**
 * hql delete 语句创建器
 * @author 卢晓峰
 */
public class HQLDeleteCreator extends AbstractHQLCreator implements
		HQLCreator {
	
	public static final String HSQL_TYPE = "delete";
	
	/* (non-Javadoc)
	 * @see com.autoabacus.core.config.provider.HSQLCreator#supports(java.lang.String)
	 */
	@Override
	public boolean supports(String hsqlType) {
		return hsqlType.equals(HSQL_TYPE);
	}

	/* (non-Javadoc)
	 * @see com.autoabacus.core.config.provider.HSQLCreator#getHSQL(com.autoabacus.core.config.Table, com.autoabacus.core.config.provider.QuerySource)
	 */
	@Override
	public String getHQL(Table table, QuerySource querySource) {
		StringBuffer hql = new StringBuffer();
		hql.append("delete ");
		hql.append(table.getName());
		addWhereSlice(table, querySource, hql);
		
		log.debug(hql.toString());
		return hql.toString();
	}

}
